//相关业务逻辑
$(function(){
	page.bind();
});


var page={//页面总变量
		bind:function(){
			$("#login").bind("click",function(){
				var userName=$("#username").val();
				var password=$("#password").val();
				if(userName==""){
					$("#username").attr("placeholder","请输入用户名");
					return false;
				}
				if(password==""){
					$("#password").attr("placeholder","请输入密码");
					return false;
				}
				userService.userLogin(userName,password);
			});
		}
}


var userService={
		userLogin:function(userName,password){
			$.ajax({
				url:'../user/login',
				type:'POST',
				data:{
					'userName':userName,
					'password':password
				},
				success:function(data){
					if(data.result){
						location.href="buttonPage.html";
					}else{
						$("#password").val("");
						$("#password").attr("placeholder",data.info);
					}
					
				}
			});
			
		}
}



//封裝alert提示框
function layAlert(str){
	layer.alert(str, {
		  skin: 'layui-layer-lan' //样式类名
		  ,closeBtn: 1
		});
}
